
var initScreen=function(callback){//初始化html  font-size
    //$("html").css("font-size",document.documentElement.clientHeight/document.documentElement.clientWidth<1.5 ? (document.documentElement.clientHeight/603*312.5+"%") : (document.documentElement.clientWidth/375*312.5+"%")); //单屏全屏布局时使用,短屏下自动缩放
    $("html").css("font-size",document.documentElement.clientWidth/320*312.5+"%");//长页面时使用,不缩放
    if(callback)callback();
};
var app = {
    init : function(){
        var _ts = this;
        _ts.addEvent();
        /*_ts.music();*/
        _ts.loading(function(){_ts.music()});
        _ts.parallax();
        _ts.swiper();
        _ts.slide1();
        _ts.slide12();
        _ts.slide13();
    },
    addEvent : function(){
        window.addEventListener("orientationchange" in window ? "orientationchange" : "resize",function(e){
            var st=setTimeout(initScreen,300);
        }, false);
    },
    music : function(){
        var btn = $(".music-btn");
        var audio = $("#music").get(0);
        btn.on('click',function(){
            if(audio.paused){
                audio.play();
                btn.find("i").removeClass('stop');
            }else{
                audio.pause();
                btn.find("i").addClass('stop');
            }
        });
        audio.play();
    },
    //加载
    loading : function(callback){
        var i = 0;
        var loadSet = setInterval(function(){
                i++;
                if(i == 100){
                    $(".loading").hide();
                    clearInterval(loadSet);
                    if(callback)callback();
                }else{
                    $(".loading .inside p").html(i+"%");
                }
            },50);
    },
    //漂浮层
    parallax : function(){
        $('#scene,#card-offset').parallax();
    },
    //整屏滑动
    swiper : function(){
        var mySwiperV = new Swiper ('.swiper-container-v', {
            direction: 'vertical',
            observer:true,
            noSwipingClass : 'stop-swiping',
            mousewheelControl : true,
            autoplayDisableOnInteraction: false,
            onInit: function(swiper){ //Swiper2.x的初始化是onFirstInit
                swiperAnimateCache(swiper); //隐藏动画元素 
                swiperAnimate(swiper); //初始化完成开始动画
            },
            onSlideChangeEnd: function(swiper){ 
                swiperAnimate(swiper); //每个slide切换结束时也运行当前slide动画
                var index = swiper.activeIndex;
                if(index == 5){
                    setTimeout(function(){$(".swiper-slide6 .cen").hide()},1200)
                }else{
                    $(".swiper-slide6 .cen").show()
                }
            }
        });
        $('.next-page').on("click",function(){
            mySwiperV.slideNext();
        })
        //mySwiperV.slideTo(11, 10, false)//切换到第一个slide，速度为1秒
    },
    slide1 : function(){
        $(".swiper-slide1").on("click",function(){
            $(this).removeClass("stop-swiping");
            $("#card-offset").addClass("hide");
            $(".click-reverse").addClass("hide");
            $(".zoom-out").addClass("zoom-in");
            $(".big-card").removeClass("run");
            $(".line").addClass("line-stop");
            setTimeout(function(){
                $(".zoom-out").addClass("yc");
                $(".next-page").removeClass("hide").addClass("show");
            },1000)
            setTimeout(function(){$(".swiper-slide1 .figure i").removeClass("hide").addClass("bounceInUp")},1500);
            setTimeout(function(){$(".swiper-slide1 .des p").eq(0).removeClass("hide").addClass("fadeInUp")},1800);
            setTimeout(function(){$(".swiper-slide1 .des p").eq(1).removeClass("hide").addClass("fadeInUp")},1900);
            setTimeout(function(){$(".swiper-slide1 .des p").eq(2).removeClass("hide").addClass("fadeInUp")},2000);
            /*$(".front").addClass("re");*/
        })
    },
    slide6 : function(){
        /*$(".swiper-slide6 .cen i").*/
    },
    slide12 : function(){
        var arr = {
            0 : {
                avatar : "/images/employee_06.png",
                department  : "市场部",
                departmentInfo : "营销策划、微信运营",
                moves : "一念三千",
                skill : "品牌、投放、PR、二次元、沟通"
            },
            1 : {
                avatar : "/images/employee_05.png",
                department  : "运营部",
                departmentInfo : "产品运营",
                moves : "运筹帷幄",
                skill : "逻辑、数据分析、活动、沟通、游戏体验"
            },
            2 : {
                avatar : "/images/employee_04.png",
                department  : "设计部",
                departmentInfo : "网页设计师",
                moves : "虚空化实",
                skill : "页面、H5、平面包装"
            },
            3 : {
                avatar : "/images/employee_03.png",
                department  : "技术部",
                departmentInfo : "前端(HTML5)工程师、<br/>Android研发工程师",
                moves : "凌波微步",
                skill : "JavaScript、jQuery、HTML/HTML5/XML、CSS/CSS3、Ajax"
            },
            4 : {
                avatar : "/images/employee_02.png",
                department  : "商务部",
                departmentInfo : "大渠道商务、<br/>渠道运营",
                moves : "铁齿铜牙",
                skill : "渠道对接、渠道扩展、沟通、数据分析"
            },
            5 : {
                avatar : "/images/employee_01.png",
                department  : "客服部",
                departmentInfo : "VIP客户服务",
                moves : "无私关怀",
                skill : "客户服务、沟通、大客户接待"
            }
        }
        $(".pop").on("click",function(){
            /*$(this).addClass("hide")*/
            $(this).hide();
        });
        $(".swiper-slide12 .bd ul li").on("click",function(){
            var index = $(this).index();
            /*$(".pop").addClass("show")*/
            var popBox = $(".pop-box");
            $(".pop").show();
            popBox.find(".avatar").removeClass("hide").addClass("bounceInDown");
            popBox.find(".info").removeClass("hide").addClass("bounceInLeft");
            popBox.find(".avatar").find("img").attr({"src":arr[index].avatar});
            $(".pop-box .info .hd .p1").html(arr[index].department);
            $(".pop-box .info .hd .p2").html(arr[index].departmentInfo);
            $(".pop-box .info .bd .p1 span").html(arr[index].moves);
            $(".pop-box .info .bd .p2 span").html(arr[index].skill);

        })
    },
    slide13 : function(){
        var mySwiperH = new Swiper ('.swiper-container-h', {
            observer:true,
            loop : true,
            autoplayDisableOnInteraction: false,
            prevButton:'.swiper-button-prev',
            nextButton:'.swiper-button-next'
        });
    }
}

$(function(){
    initScreen(function(){
        app.init();
    })
    
})